#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
__author__ = "Administrator"
__name__="redishelper"
__date__="2016/8/12"
__time__="19:11"
"""
import redis

class RedisHelper:
    def __init__(self):
        self.__conn = redis.Redis(host='192.168.4.129')    # 定义私有字段
        self.chan_sub = 'fm87.7'
        self.chan_pub = 'fm104.5'
    def get(self,key):
        return self.__conn.get(key) # 访问私有字段
    def set(self,key,value):
        self.__conn.set(key,value)
    def public(self,msg):
        self.__conn.publish(self.chan_pub,msg)
    def subscribe(self):
        pub = self.__conn.pubsub()
        pub.subscribe(self.chan_sub)
        pub.parse_response()
        return pub
if __name__ == '__main__':
    t = RedisHelper()
    t.public('test')